<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>#{bundle.ugroup}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
            <h:form >
               <script type="text/javascript">                      
                    initFormUgroup = function(){
                       // $("input.money").autoNumeric({aSep:",",aDec:".",mDec:2,mNum:15});                        
                    }
                    function handleSaveUgroup(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                            dlgUgroup.hide();  
                        }  
                    }

                    function handleDeleteUgroup(xhr, status, args) {  
                        if(args.validationFailed || !args.success) {  
                            jQuery('dialog').effect("shake", { times:3 }, 100);  
                        } else {  
                            dlgDelUgroup.hide();  
                        }  
                    }
                </script>

                <p:toolbar>
                    <p:toolbarGroup align="left">
                        <p:commandButton value="#{bundle.btnNew}"
                                         image="ui-icon-document"  rendered="#{menuBean.cekButtonAccess(602,'INS;')}" 
                                         action="#{ugroupBean.newData()}"  
                                         oncomplete="dlgUgroup.show()"
                                         process="@this"
                                         update=":#{utilityBean.findClientId('displayUgroup')}"> 
                            <pe:resetEditableValues for="displayUgroup" />
                        </p:commandButton>

                        <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgUgroup.show()"
                                         image="ui-icon-disk" action="#{ugroupBean.openData()}"
										 rendered="#{menuBean.cekButtonAccess(602,'OPN;')}" 
                                         update=":#{utilityBean.findClientId('displayUgroup')}" > 
                        </p:commandButton>

                        <p:commandButton type="button" value="#{bundle.btnDelete}" image="ui-icon-trash"
                                         onclick="dlgConfirmation.show()" action="#{ugroupBean.delete()}"
										 rendered="#{menuBean.cekButtonAccess(602,'DEL;')}" 
                                         update=":#{utilityBean.findClientId('displayUgroup')}" /> 

                        <!--<p:commandButton type="push" value="#{bundle.btnPrint}" image="ui-icon-print"/>-->
                    </p:toolbarGroup>
                </p:toolbar>
                <br />
                <p:dataTable id="dtUgroups" var="ugroup" value="#{ugroupBean.ugroup}" rowIndexVar="noUrut"
                             rowKey="#{ugroup.ugroupId}" selectionMode="single" selection="#{ugroupBean.selectedData}"
                                 paginator="true" rows="10" paginatorPosition="bottom" 
                                 rowsPerPageTemplate="5,10,15,30" 
                                 paginatorTemplate="{CurrentPageReport} {PreviousPageLink} {NextPageLink} {RowsPerPageDropdown}"
                                 resizableColumns="true">
                    <p:column style="width: 10px">
                        <f:facet name="header">No.</f:facet>
                        <h:outputText value="#{noUrut+1}" />
                    </p:column>
                    <p:column  style="width: 250px" sortBy="#{ugroup.ugroupName}">
                         <f:facet name="header">#{bundle.globalName}</f:facet>
                        <h:outputText value="#{ugroup.ugroupName}" />
                    </p:column>
                    <p:column  style="width: 300px" sortBy="#{ugroup.description}">
                        <f:facet name="header">#{bundle.description}</f:facet>
                        <h:outputText value="#{ugroup.description}" />
                    </p:column>
                    <p:column  style="width: 100px"  styleClass="money">
                        <f:facet name="header">#{bundle.savMaxDeposit}</f:facet>
                    <h:outputText value="#{ugroup.savMaxDeposit}">
                            <f:convertNumber groupingUsed="#{true}"/>
                        </h:outputText>                  
                   </p:column>
                    <p:column  style="width: 100px"  styleClass="money">
                        <f:facet name="header">#{bundle.savMaxWD}</f:facet>
                        <h:outputText value="#{ugroup.savMaxWd}"  styleClass="money"><f:convertNumber groupingUsed="#{true}"/></h:outputText>
                    </p:column>
                    <p:column  style="width: 100px"  styleClass="money">
                        <f:facet name="header">#{bundle.savMaxTrx}</f:facet>
                        <h:outputText value="#{ugroup.savMaxTrx}" styleClass="money" ><f:convertNumber groupingUsed="#{true}"/></h:outputText>
                    </p:column>
                    <p:column style="width: 100px" styleClass="money">
                        <f:facet name="header">#{bundle.depMaxDeposit}</f:facet>
                        <h:outputText value="#{ugroup.depMaxDeposit}" styleClass="money" ><f:convertNumber groupingUsed="#{true}"/></h:outputText>
                    </p:column>
                    <p:column style="width: 100px" styleClass="money">
                        <f:facet name="header">#{bundle.loanMaxDsb}</f:facet>
                        <h:outputText value="#{ugroup.loanMaxDisb}" styleClass="money" ><f:convertNumber groupingUsed="#{true}"/></h:outputText>
                    </p:column>
                </p:dataTable>
                 <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                             header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDelUgroup">  
                <p:commandButton value="#{bundle.btnYes}" update="dtUgroups" 
                                 oncomplete="handleDeleteUgroup(xhr, status, args)"  
                                 actionListener="#{glaccntBean.delete()}" />  
                <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDelUgroup.hide()" type="button" />   
            </p:confirmDialog>
               
            </h:form>
            <p:dialog onShow="initFormUgroup()" header="#{bundle.ugroup}" widgetVar="dlgUgroup" closable="true" dynamic="true"  modal="true" appendToBody="true">
                    
                    <p:ajax immediate="true" event="close" listener="#{ugroupBean.handleClose}"/>
                    <h:form>
                    <h:panelGrid id="displayUgroup" columns="2" styleClass="addELIT">
                        <h:outputLabel value= "#{bundle.globalName} :" />                        
                        <p:inputText rendered="#{ugroupBean.insertedData!=null}" value="#{ugroupBean.insertedData.ugroupName}" />

                        <h:outputLabel value= "#{bundle.description} :" />
                        
                        <p:inputTextarea autoResize="false" rendered="#{ugroupBean.insertedData!=null}" rows="1" cols="50" value="#{ugroupBean.insertedData.description}" />

                        <h:outputLabel value= "#{bundle.savMaxDeposit} :" />
                        <pe:inputNumber decimalSeparator="." thousandSeparator="," minValue="0" 
                                styleClass="money" value="#{ugroupBean.insertedData.savMaxDeposit}" style="width: 170px"
                                required="false" label="#{bundle.savMaxDeposit}" 
                                requiredMessage="#{bundle.savMaxDeposit} #{bundle.requiredInput}">                                
                            </pe:inputNumber>    
                    <!--    <p:inputText id="txtMaxDeposit2" styleClass="money"  rendered="#{ugroupBean.selectedData!=null}" value="#{ugroupBean.selectedData.savMaxDeposit}" >
                         <f:convertNumber groupingUsed="#{true}"/>  </p:inputText> 
                        <p:inputText id="txtMaxDeposit" styleClass="money" rendered="#{ugroupBean.insertedData!=null}" value="#{ugroupBean.insertedData.savMaxDeposit}" >
                          <f:convertNumber groupingUsed="#{true}"/> 
                        </p:inputText> -->
                            
                        
                        <h:outputLabel value= "#{bundle.savMaxWD} :" />
                         <pe:inputNumber decimalSeparator="." thousandSeparator="," minValue="0" 
                                styleClass="money" value="#{ugroupBean.insertedData.savMaxWd}" style="width: 170px"
                                required="false" label="#{bundle.savMaxWD}" 
                                requiredMessage="#{bundle.savMaxWD} #{bundle.requiredInput}">                                
                            </pe:inputNumber> 
                        <!-- <p:inputText styleClass="money" rendered="#{ugroupBean.insertedData!=null}" value="#{ugroupBean.insertedData.savMaxWd}" >
                          <f:convertNumber groupingUsed="#{true}"/>
                        </p:inputText> -->

                        <h:outputLabel style="padding:0 15px 0 0;" value= "#{bundle.savMaxTrx} :" />
                        
                       <!-- <p:inputText styleClass="money" rendered="#{ugroupBean.insertedData!=null}" value="#{ugroupBean.insertedData.savMaxTrx}" ><f:convertNumber groupingUsed="#{true}"/></p:inputText> -->
                         <pe:inputNumber decimalSeparator="." thousandSeparator="," minValue="0" 
                                styleClass="money" value="#{ugroupBean.insertedData.savMaxTrx}" style="width: 170px"
                                required="false" label="#{bundle.savMaxTrx}" 
                                requiredMessage="#{bundle.savMaxTrx} #{bundle.requiredInput}">                                
                            </pe:inputNumber> 

                        <h:outputLabel value= "#{bundle.depMaxDeposit} :" />
                        
                      <!--  <p:inputText styleClass="money" rendered="#{ugroupBean.insertedData!=null}" value="#{ugroupBean.insertedData.depMaxDeposit}" ><f:convertNumber groupingUsed="#{true}"/></p:inputText> -->
                        <pe:inputNumber decimalSeparator="." thousandSeparator="," minValue="0" 
                                styleClass="money" value="#{ugroupBean.insertedData.depMaxDeposit}" style="width: 170px"
                                required="false" label="#{bundle.depMaxDeposit}" 
                                requiredMessage="#{bundle.depMaxDeposit} #{bundle.requiredInput}">                                
                            </pe:inputNumber>

                        <h:outputLabel value= "#{bundle.loanMaxDsb} :" />
                        
                        <!-- <p:inputText styleClass="money" rendered="#{ugroupBean.insertedData!=null}" value="#{ugroupBean.insertedData.loanMaxDisb}" ><f:convertNumber groupingUsed="#{true}"/></p:inputText> -->
                        <pe:inputNumber decimalSeparator="." thousandSeparator="," minValue="0" 
                                styleClass="money" value="#{ugroupBean.insertedData.loanMaxDisb}" style="width: 170px"
                                required="false" label="#{bundle.loanMaxDsb}" 
                                requiredMessage="#{bundle.loanMaxDsb} #{bundle.requiredInput}">                                
                            </pe:inputNumber>
                    </h:panelGrid>

                    <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                        <f:facet name="footer">
                            <p:commandButton value="#{bundle.btnSave}" image="ui-icon-disk" action="#{ugroupBean.save}" rendered="#{menuBean.cekButtonAccess(602,'UPD;')}" 
                                             update=":#{utilityBean.findClientId('dtUgroups')}"       
                                             oncomplete="handleSaveUgroup(xhr, status, args)"/>  
                            <p:commandButton immediate="true" value="#{bundle.btnClose}" oncomplete="dlgUgroup.hide()" image="ui-icon-document"/>
                        </f:facet>
                    </h:panelGrid>
                        </h:form>
                </p:dialog>
            
       </ui:composition>     
    </h:body>
</html>
